%Declare the symbolic variables (syms)
syms bVal tauVal PBVal PBLagVal YLagVal YVal piVal bLagVal
f= -b*exp(bVal) -tau*exp(tauVal) + (1+rho*Pb*exp(PBVal))/(Pb*exp(PBLagVal)) * Y*exp(YLagVal) / (Y*exp(YVal))/ (PI*exp(piVal))* (b*exp(bLagVal));

%Take symbolic derivatives
dd1 = diff(f,bVal);
dd2 = diff(f,tauVal);
dd3 = diff(f,PBVal);
dd4 = diff(f,PBLagVal);
dd5 = diff(f,YLagVal);
dd6 = diff(f,YVal);
dd7 = diff(f,piVal);
dd8 = diff(f,bLagVal);

%Evaluates symbolic derivatives

bVal=0;  %loglin
tauVal=0;  %loglin
PBVal=0;  %loglin
PBLagVal=0;  %loglin
YLagVal=0;  %loglin
YVal=0;  %loglin
piVal=0;  %loglin
bLagVal=0;  %loglin

D1=subs(dd1);
D2=subs(dd2);
D3=subs(dd3);
D4=subs(dd4);
D5=subs(dd5);
D6=subs(dd6);
D7=subs(dd7);
D8=subs(dd8);

% Transform symbolic into numbers (with double precision)
d1=double(D1);
d2=double(D2);
d3=double(D3);
d4=double(D4);
d5=double(D5);
d6=double(D6);
d7=double(D7);
d8=double(D8);

ACont(ii,bcLog)         = d1;
ACont(ii,taucLog)       = d2;
ACont(ii,pbcLog)        = d3;
ALag(ii,pbcLog)         = -d4;
ALag(ii,YcLog)          = -d5;
ACont(ii,YcLog)         = d6;
ACont(ii,picLog)        = d7;
ALag(ii,bcLog)          = -d8;
